package com.bocai.kelalacar.ui.car.order.ada;

import android.graphics.Color;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import com.bocai.kelalacar.R;
import com.bocai.kelalacar.base.BaseRecyclerAdapter;
import com.bocai.kelalacar.base.BaseRecyclerViewHolder;
import com.bocai.kelalacar.bean.MyGradOrderBean;
import com.bocai.kelalacar.util.DoubleUtil;
import com.bumptech.glide.Glide;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by yuanfei on 2017/6/21.
 */

public class RushOrderAda extends BaseRecyclerAdapter<MyGradOrderBean.OrderListBean> {


    @Override
    public void showData(BaseRecyclerViewHolder viewHolder, int i, List<MyGradOrderBean.OrderListBean> mItemDataList) {

        MyViewHolder myViewHolder = (MyViewHolder) viewHolder;
        myViewHolder.tvMoney.setText("￥"+ DoubleUtil.m2(mItemDataList.get(i).getPrice()));
        myViewHolder.tvStartAddress.setText(mItemDataList.get(i).getOriginCity().replace("市",""));
        myViewHolder.tvEndAddress.setText(mItemDataList.get(i).getArriveCity().replace("市",""));
        myViewHolder.tvStartData.setText(mItemDataList.get(i).getBeginTime());
        myViewHolder.tvData.setText("该用车请求于 "+mItemDataList.get(i).getCreateTime()+" 发布");
        myViewHolder.tvType.setText(mItemDataList.get(i).getApplySeats()+"座");
//        Glide.with(getContext()).load(mItemDataList.get(i))
        if (mItemDataList.get(i).getOrderStatus() == 1){
            myViewHolder.btn.setText("抢单(待支付)");
        }else if (mItemDataList.get(i).getOrderStatus() == 2&&!mItemDataList.get(i).isHasDriver()){
            myViewHolder.btn.setText("抢单(待完善)");
        }else if (mItemDataList.get(i).getOrderStatus() == 2&&mItemDataList.get(i).isHasDriver()){
            myViewHolder.btn.setText("抢单(待出发)");
        }else if (mItemDataList.get(i).getOrderStatus() == 3){
            myViewHolder.btn.setText("抢单(已完成)");
        }else if (mItemDataList.get(i).getOrderStatus() == 5){
            myViewHolder.btn.setText("抢单(行程中)");
        }else {
            myViewHolder.btn.setText("抢单(已关闭)");
        }

    }

    @Override
    public int getListLayoutId() {
        return R.layout.item_rush_order;
    }

    @Override
    public RecyclerView.ViewHolder createViewHolder(View view) {
        return new MyViewHolder(view);
    }

    class MyViewHolder extends BaseRecyclerViewHolder {
        @BindView(R.id.tv_name)
        TextView tvName;
        @BindView(R.id.tv_type)
        TextView tvType;
        @BindView(R.id.tv_start_address)
        TextView tvStartAddress;
        @BindView(R.id.tv_start_data)
        TextView tvStartData;
        @BindView(R.id.tv_money)
        TextView tvMoney;
        @BindView(R.id.tv_end_address)
        TextView tvEndAddress;
        @BindView(R.id.tv_data)
        TextView tvData;
        @BindView(R.id.btn)
        Button btn;
        @BindView(R.id.head_img)
        ImageView headImg;
        public MyViewHolder(View itemView) {
            super(itemView);
            ButterKnife.bind(this, itemView);
        }
    }
}
